﻿using AutoMapper;
using BW.MesProject.BasicData.Domain.Dto;
using BW.MesProject.BasicData.Domain.基础;
using BW.MesProject.BasicData.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace BW.MesProject.BasicData.Host.Controllers
{
    /// <summary>
    /// 产线管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionlineController : ControllerBase
    {
        private readonly IProductionlineServices productionlineServices;

        public ProductionlineController(IProductionlineServices productionlineServices)
        {
            this.productionlineServices = productionlineServices;
        }
        /// <summary>
        /// 添加产线
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddProductionline(ProductionlineModel model)
        {
          return productionlineServices.AddProductionline(model);
        }

        /// <summary>
        /// 删除产线
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> DeleteProductionline(long id)
        {
            return productionlineServices.DeleteProductionline(id);
        }
        /// <summary>
        /// 查询产线
        /// </summary>
        /// <param name="productionlinecode"></param>
        /// <param name="Productionlinename"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<List<ProductionlineDto>> GetProductionline(string? productionlinecode, string? Productionlinename, int pageindex, int pagesize)
        {
          return productionlineServices.GetProductionline(productionlinecode, Productionlinename, pageindex, pagesize);

        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public ApiResult<int> UpdateProductionline(ProductionlineModel model)
        {
            return productionlineServices.UpdateProductionline(model);
        }
        /// <summary>
        /// 查询ById
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<ProductionlineModel> GetProductionlineById(long id)
        {
           return productionlineServices.GetProductionlineById(id);
        }
        /// <summary>
        /// 获取所有产线
        /// </summary>
        /// <returns>产线列表</returns>
        [HttpGet]
        public ApiResult<List<ProductionlineModel>> GetAllProductionline()
        {
           return productionlineServices.GetAllProductionline();
        }
    }
}
